package effect;

import card.CreatureCard;
import core.MapUtil;
import effect.Effect.EffectType;
import effect.Effect.TargetType;

public class Haste extends Effect {
	
	private boolean active;
	
	public Haste(){
		name="Haste";
		description="The unit gains one extra action this turn.";
		imageName="cardIconHaste.png";
		effectTypes.add(EffectType.activatable);
		effectTypes.add(EffectType.triggerOnTurnEnd);
		targetType = TargetType.none;
		manaCost=3;
		active=false;
	}
	
	@Override
	public void triggerOnTurnEnd(){
		active=false;
		CreatureCard temp = (CreatureCard) EffectUtil.getCard(this);
		if(temp.getActionsLeft()>temp.getMaxActions())
			temp.setActionsLeft(temp.getActionsLeft()-1);
	}
	
	@Override
	public void activate(){
		EffectUtil.getCard(this).getOwner().addMana(-3);
		
		CreatureCard temp = (CreatureCard) EffectUtil.getCard(this);
		temp.setActionsLeft(temp.getActionsLeft()+1);
		active=true;
	}
	
	@Override
	public boolean canActivate(){
		if(EffectUtil.getCard(this).getOwner().getMana()>=3 &&
				active==false)
			return true;
		else
			return false;
	}
	
	@Override
	public String getDescription(){
		if(active==true)
			return "The unit is hasted.";
		else
			return "The unit gains one extra action this turn.";
	}
}
